首页

欢迎

 

Welcome

欢迎, 这是一个学习数学、讨论数学的网站.

转到问题

请输入问题号, 例如: 2512

IMAGINE, THINK, and DO
How to be a scientist, mathematician and an engineer, all in one?
--- S. Muthu Muthukrishnan

Local Notes

Local Notes 是一款 Windows 下的笔记系统.

Local Notes 下载

Sowya

Sowya 是一款运行于 Windows 下的计算软件.

详情

下载 Sowya.7z (包含最新版的 Sowya.exe and SowyaApp.exe)


注: 自 v0.550 开始, Calculator 更名为 Sowya. [Sowya] 是吴语中数学的发音, 可在 cn.bing.com/translator 中输入 Sowya, 听其英语发音或法语发音.





注册

欢迎注册, 您的参与将会促进数学交流. 注册

在注册之前, 或许您想先试用一下. 测试帐号: usertest 密码: usertest. 请不要更改密码.


我制作的 slides

Problem

随机显示问题

Problèmes d'affichage aléatoires

软件 >> C++ >> Visual Studio
Questions in category: Visual Studio (Visual Studio).

关于 fopen() 函数

Posted by haifeng on 2021-03-02 13:44:00 last update 2021-03-02 15:55:32 | Answers (0)


在使用 VS2019 时, 如果代码中使用了 fopen() 函数, 则在编译时会显示如下警告.  C4996. 提示使用 fopen_s()

 

严重性 代码 说明 项目 文件 行 禁止显示状态
错误 C4996 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. studentsMS D:\work\cs\c++\database\StudentsMangementSystem\studentsMS\studentsMS\studentsMS.cpp 28

 

fopen() 函数的原型是

FILE *fopen( const char *filename, const char *mode );

而 fopen_s() 函数的原型是

errno_t fopen_s( FILE** pFile, const char *filename, const char *mode );

 

fp = fopen("users.txt", "rb+");

应该为

fopen_s(&fp, "users.txt", "rb+");

 

 

 

References:

https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/fopen-wfopen?view=msvc-160

https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/fopen-s-wfopen-s?view=msvc-160